﻿using SUNRPA.CONTROLS.IMPL.domain.attrubutes;
using SUNRPA.CONTROLS.IMPL.domain.flowRunningVar;
using SUNRPA.CONTROLS.IMPL.util;
using System.Collections.Concurrent;
namespace SUNRPA.CONTROLS.IMPL.domain.flowItemParam {
    [Serializable]
    [VarFieldName("LoopIndexOut", "LoopItemOut")]
    public class LoopExcelNParam:BaseParam {
        private string loopObject = "{excelObject}";
        //0已使用区域，1循环区域，2行，3列
        private int loopType = 0;
        private string startRow;
        private string startColumn;
        private string endRow;
        private string endColumn;
        private string sheetName;
        //读取单元格肉眼所见内容，否则1会变成1.0，日期回事日期对象
        private bool readShowsContent = false;
        private bool trimContent = false;
        private string loopItemOut = "loopItem";
        private string loopIndexOut = "loopIndex";

        public string GetTranslateLoopType() {
            switch(this.loopType) {
                case 0:
                    return "已使用区域";
                case 1:
                    return $"区域起始单元格[{startRow},{startColumn}],结束单元格[{endRow},{endColumn}]";
                case 2:
                    return $"行，起始行号{startRow},结束行号{endRow}";
                case 3:
                    return $"列，起始列名{startColumn}，结束列名{EndColumn}";
                default:
                    return "已使用区域";
            }
        }

        public int LoopType {
            get => loopType; 
            set { 
                loopType = value;
                NotifyPropertyChanged("LoopType");
            }  
        }

        public string LoopItemOut {
            get => loopItemOut; 
            set { 
                loopItemOut = value;
                NotifyPropertyChanged("LoopItemOut");
            }  
        }

        public string LoopIndexOut {
            get => loopIndexOut; 
            set { 
                loopIndexOut = value;
                NotifyPropertyChanged("LoopIndexOut");
            }  
        }
        public string LoopObject {
            get => loopObject; 
            set { 
                loopObject = value;
                NotifyPropertyChanged("LoopObject");
            }  
        }
        public bool ReadShowsContent { 
            get => readShowsContent; 
            set { 
                readShowsContent = value;
                NotifyPropertyChanged("ReadShowsContent");
            }  
        }

        public bool TrimContent { 
            get => trimContent; 
            set { 
                trimContent = value;
                NotifyPropertyChanged("TrimContent");
            }  
        }

        public string SheetName {
            get => sheetName; 
            set { 
                sheetName = value;
                NotifyPropertyChanged("SheetName");
            }  
        }
        public string StartRow {
            get => startRow; 
            set { 
                startRow = value;
                NotifyPropertyChanged("StartRow");
            }  
        }

        public string EndRow {
            get => endRow; 
            set { 
                endRow = value;
                NotifyPropertyChanged("EndRow");
            }  
        }

        public string StartColumn {
            get => startColumn; 
            set { 
                startColumn = value;
                NotifyPropertyChanged("StartColumn");
            }  
        }

        public string EndColumn {
            get => endColumn; 
            set { 
                endColumn = value;
                NotifyPropertyChanged("EndColumn");
            }  
        }
        public override void SetLatestVarName(ConcurrentDictionary<string, ConcurrentDictionary<string, RPAVariableDefineWrapper>> globleData) {
            this.loopIndexOut = this.GetLatestName(this.loopIndexOut, globleData);
            this.loopItemOut = this.GetLatestName(this.loopItemOut, globleData);
        }
    }
}
